package com.faxsun.core.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import mblog.core.persist.dao.PostDao;
import mblog.core.pojos.Post;
import mblog.core.utils.BeanMapUtils;

import com.faxsun.core.persist.entity.PostPO;
import com.faxsun.core.pojos.enums.PostType;
import com.faxsun.core.service.HotspotService;

public class HotspotServiceImpl implements HotspotService {

	@Autowired
	private PostDao postDao;
	
	@Override
	@Transactional(readOnly=true)
	public List<Post> top(int topNum, PostType type) {
		List<PostPO> hotSpots = postDao.findHots(topNum, type);
		List<Post> rets = new ArrayList<Post>();
		for (PostPO po : hotSpots) {
			rets.add(BeanMapUtils.copy(po, 0));
		}
		return rets;
	}

}
